package com.my.study.design.decorator;

/**
 * @author Carlos
 * @version 1.0
 * @Description 装饰者
 * 组合 + 继承
 *
 * @date 2021/7/18 18:33
 **/
public class Decorator extends Drink {

    private Drink drink;

    public Decorator(Drink drink) {
        this.drink = drink;
    }

    @Override
    protected float cost() {
        // 自己的价格 + 饮品的价格
        return super.getPrice() + drink.cost();
    }

    @Override
    public String getDes() {
        return super.getDes() + "" + super.getPrice() + " &&" + drink.getDes();
    }
}
